<template>
  <div>
    <div class="i">
      <img src="../../assets/img/6.jpg" alt />
    </div>
    <span>还有{{ title }}秒跳转到首页面</span>
  </div>
</template>

<script>
export default {
  data() {
    return {
      time: null,
      title: "",
      num: 5,
    };
  },
  async mounted() {
    let time = setInterval(() => {
      this.num--,
        //  window.confirm(`还有${this.num}秒后跳转到首页面`)
        (this.title = `${this.num}`);
      if (this.num === 0) {
        clearInterval(time);
        this.$router.push({ path: "/main" });
      }
    }, 1000);
    this.$store.dispatch("main/setShowBtoNav", false);
  },
};
</script>

<style lang="scss" scoped>
body,
html {
  width: 100%;
  height: 100%;
}
.i {
  width: 100%;
  height: 100%;
  img {
    width: 100%;
    height: 100%;
  }
}
span{
    display:block;
    width:100%;
    height:0.2rem;
    position:absolute;
    top:0;
    left:0;
    font-size:.3rem;
}
</style>
